package com.kkb.service.ordermanager.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.bean.OrderTable;
import com.kkb.dao.OrderTableMapper;
import com.kkb.service.ordermanager.OrderManagerService;
import com.kkb.vo.ordermanager.req.SelectOrderReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderManagerServiceImpl implements OrderManagerService {

    @Autowired
    private OrderTableMapper orderTableMapper;

    /**
     * 查询订单
     * @param param
     * @return
     */
    @Override
    public PageInfo<OrderTable> selectOrder(SelectOrderReq param) {
        //创建tkmybatis查询参数
        OrderTable order = new OrderTable();
        order.setSellerId(param.getSellerId());
        order.setCommodityType(param.getCommodityType());
        //1.指定分页数据
        PageHelper.startPage(param.getPageNum(),param.getPageSize());
        //2.查询数据
        List<OrderTable> orders = orderTableMapper.select(order);
        //3.创建分页工具类
        PageInfo<OrderTable> orderTablePageInfo = new PageInfo<>(orders);
        return orderTablePageInfo;

    }
}
